#include "comm.hpp"

int main()
{
    int shfd = GetShm();
    // 获取指向共享内存的起始地址
    char* shmaddr = (char*)shmat(shfd,nullptr,0);

    int fd = open(FIFO_FILE,O_WRONLY);
    if(fd < 0)
    {
        logbook(Fatal,"error string: %s, error code: %d",strerror(errno),errno);
        exit(FIFO_OPEN_ERR);
    }
    
    while (true)
    {
        std::cout << "Please Enter@ ";
        std::string line;
        fgets(shmaddr,MEMSIZE,stdin);

        write(fd,"c",1);    // 通过管道通知对方开始读取
    }
    shmdt(shmaddr);

    close(fd);

    return 0;
}